package com.panda.order.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.panda.common.annotation.Log;
import com.panda.common.core.controller.BaseController;
import com.panda.common.core.domain.AjaxResult;
import com.panda.common.enums.BusinessType;
import com.panda.order.domain.TPandaOrderBuyer;
import com.panda.order.service.ITPandaOrderBuyerService;
import com.panda.common.utils.poi.ExcelUtil;
import com.panda.common.core.page.TableDataInfo;

/**
 * 淘宝买家信息Controller
 * 
 * @author panda
 * @date 2021-03-14
 */
@RestController
@RequestMapping("/order/buyer")
public class TPandaOrderBuyerController extends BaseController
{
    @Autowired
    private ITPandaOrderBuyerService tPandaOrderBuyerService;

    /**
     * 查询淘宝买家信息列表
     */
    @PreAuthorize("@ss.hasPermi('order:buyer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPandaOrderBuyer tPandaOrderBuyer)
    {
        startPage();
        List<TPandaOrderBuyer> list = tPandaOrderBuyerService.selectTPandaOrderBuyerList(tPandaOrderBuyer);
        return getDataTable(list);
    }

    /**
     * 导出淘宝买家信息列表
     */
    @PreAuthorize("@ss.hasPermi('order:buyer:export')")
    @Log(title = "淘宝买家信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPandaOrderBuyer tPandaOrderBuyer)
    {
        List<TPandaOrderBuyer> list = tPandaOrderBuyerService.selectTPandaOrderBuyerList(tPandaOrderBuyer);
        ExcelUtil<TPandaOrderBuyer> util = new ExcelUtil<TPandaOrderBuyer>(TPandaOrderBuyer.class);
        return util.exportExcel(list, "buyer");
    }

    /**
     * 获取淘宝买家信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:buyer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPandaOrderBuyerService.selectTPandaOrderBuyerById(id));
    }

    /**
     * 新增淘宝买家信息
     */
    @PreAuthorize("@ss.hasPermi('order:buyer:add')")
    @Log(title = "淘宝买家信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPandaOrderBuyer tPandaOrderBuyer)
    {
        return toAjax(tPandaOrderBuyerService.insertTPandaOrderBuyer(tPandaOrderBuyer));
    }

    /**
     * 修改淘宝买家信息
     */
    @PreAuthorize("@ss.hasPermi('order:buyer:edit')")
    @Log(title = "淘宝买家信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPandaOrderBuyer tPandaOrderBuyer)
    {
        return toAjax(tPandaOrderBuyerService.updateTPandaOrderBuyer(tPandaOrderBuyer));
    }

    /**
     * 删除淘宝买家信息
     */
    @PreAuthorize("@ss.hasPermi('order:buyer:remove')")
    @Log(title = "淘宝买家信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPandaOrderBuyerService.deleteTPandaOrderBuyerByIds(ids));
    }
}
